/*
 * TitechBoard.hpp
 *
 *  Created on: Aug 3, 2009
 *      Author: naveenoid
 */

#ifndef TITECHBOARD_HPP_
#define TITECHBOARD_HPP_

/*
 * Includes
 */

#include "ftd2xx.h"
#include <vector>
#include <string>
#include <ecl/threads.hpp>
#include "./../Common/Common.hpp"

using std::vector;
using std::string;
using ECL::Threads::Mutex;
using namespace Octopus::BoardSetup::FTD2xx;

namespace Octopus {

namespace BoardSetup {

class TitechBoard {
public:
	static TitechBoard* getInstance();
	void remove();

	bool deviceCanCom(void);
	bool deviceTimeOutIsSet(void);
	bool deviceIsOpen(void);

	vector<int> readAD(void);
	bool writeMotor(int,int);
	bool writeMotors(vector<int>);


protected:
	TitechBoard(int readTimeOut = READ_TIMEOUT, int writeTimeOut = WRITE_TIMEOUT);
	virtual ~TitechBoard();

private:
	static TitechBoard* instance;

	FT_HANDLE ftHandle;
	bool openStatus;
	bool comStatus;
	bool timeOutStatus;
	Mutex mutex;

	bool openDevice(void);
	bool setDeviceComCharacteristics(void);
	bool setTimeOut(int readTimeOut = READ_TIMEOUT, int writeTimeOut = WRITE_TIMEOUT);
	bool closeDevice(void);

	bool writeData(string);
};

}

}
#endif /* TITECHBOARD_HPP_ */
